﻿Imports System.Data.SqlClient

Public Class frmEvaluacionInterna
    Dim cont As Integer
    Dim cont2 As Integer
    Dim limite As Integer
    Dim numero As Integer
    Dim EvaDeta As New clsEvaluacionInternaDetalle
    Dim EvaTotal As New clsEvaluacionInternaTotales
    Dim Bitacora As New clsActividad
    Private Sub frmEvaluacionInterna_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolStrip2.Cursor = Cursors.Hand
        ToolStrip2.RenderMode = System.Windows.Forms.ToolStripRenderMode.System
        ToolStrip2.Stretch = True
        EmpleadoID = frmModuloEmpleados.dgEmpleados.CurrentRow.Cells(0).Value
        Dim EmpleadoSelect As String = BuscarStrDatoCitra("Empleados", "NombreCompleto", "IdEmpleado=" & EmpleadoID)

        Dim fecha As Date = Now()
        Me.txtAnio.Text = fecha.Year
        If EmpleadoSelect = "" Then
            Me.lblNombre.Text = "Indicar un empleado"
        Else
            Me.lblNombre.Text = EmpleadoSelect
        End If


        cont = 0
        cont2 = 0
        limite = frmModuloEmpleados.dgEmpleados.Rows.Count - 1
        Me.lstMeses.Text = ""
        numero = 0
        limpia()
    End Sub
    Sub limpia()
        Me.eva1.Checked = False
        Me.eva2.Checked = False
        Me.eva3.Checked = False
        Me.eva4.Checked = False

        Me.die1.Text = 0
        Me.die2.Text = 0
        Me.die3.Text = 0
        Me.die4.Text = 0
        Me.cui1.Text = 0
        Me.cui2.Text = 0
        Me.cui3.Text = 0
        Me.cui4.Text = 0
        Me.man1.Text = 0
        Me.man2.Text = 0
        Me.man3.Text = 0
        Me.man4.Text = 0
        Me.usu1.Text = 0
        Me.usu2.Text = 0
        Me.usu3.Text = 0
        Me.usu4.Text = 0
        Me.dis1.Text = 0
        Me.dis2.Text = 0
        Me.dis3.Text = 0
        Me.dis4.Text = 0
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
    Private Sub eva1_ToggleStateChanged(ByVal sender As System.Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs) Handles eva1.ToggleStateChanged
        If eva1.Checked = True Then
            numero = numero + 1
            Me.die1.Text = 3
            Me.cui1.Text = 3
            Me.man1.Text = 3
            Me.usu1.Text = 3
            Me.dis1.Text = 3

        Else
            If numero > 0 Then
                numero = numero - 1
            End If
            Me.die1.Text = 0
            Me.cui1.Text = 0
            Me.man1.Text = 0
            Me.usu1.Text = 0
            Me.dis1.Text = 0
            total1.Text = 0


        End If
    End Sub

    Private Sub eva2_ToggleStateChanged(ByVal sender As System.Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs) Handles eva2.ToggleStateChanged
        If eva2.Checked = True Then
            numero = numero + 1
            Me.die2.Text = 3
            Me.cui2.Text = 3
            Me.man2.Text = 3
            Me.usu2.Text = 3
            Me.dis2.Text = 3

        Else
            If numero > 0 Then
                numero = numero - 1
            End If
            Me.die2.Text = 0
            Me.cui2.Text = 0
            Me.man2.Text = 0
            Me.usu2.Text = 0
            Me.dis2.Text = 0
            total2.Text = 0


        End If
    End Sub

    Private Sub eva3_ToggleStateChanged(ByVal sender As System.Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs) Handles eva3.ToggleStateChanged
        If eva3.Checked = True Then
            numero = numero + 1
            Me.die3.Text = 3
            Me.cui3.Text = 3
            Me.man3.Text = 3
            Me.usu3.Text = 3
            Me.dis3.Text = 3

        Else
            If numero > 0 Then
                numero = numero - 1
            End If
            Me.die3.Text = 0
            Me.cui3.Text = 0
            Me.man3.Text = 0
            Me.usu3.Text = 0
            Me.dis3.Text = 0
            total3.Text = 0

        End If
    End Sub

    Private Sub eva4_ToggleStateChanged(ByVal sender As System.Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs) Handles eva4.ToggleStateChanged
        If eva4.Checked = True Then
            numero = numero + 1
            Me.die4.Text = 3
            Me.cui4.Text = 3
            Me.man4.Text = 3
            Me.usu4.Text = 3
            Me.dis4.Text = 3

        Else
            If numero > 0 Then
                numero = numero - 1
            End If
            Me.die4.Text = 0
            Me.cui4.Text = 0
            Me.man4.Text = 0
            Me.usu4.Text = 0
            Me.dis4.Text = 0
            total4.Text = 0

        End If
    End Sub

    Private Sub die1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles die1.TextChanged
        If die1.Text = "" Then
            die1.Text = 0
        End If
        If Me.die1.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            die1.Text = 3
        End If
        Try
            total1.Text = (1 * (die1.Text) + 1 * (cui1.Text) + 1 * (man1.Text) + 1 * (usu1.Text) + 1 * (dis1.Text))
            rentotal.Text = (1 * (die1.Text) + 1 * (die2.Text) + 1 * (die3.Text) + 1 * (die4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try

    End Sub

    Private Sub cui1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cui1.TextChanged
        If cui1.Text = "" Then
            cui1.Text = 0
        End If
        If Me.cui1.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            cui1.Text = 3
        End If
        Try
            total1.Text = (1 * (die1.Text) + 1 * (cui1.Text) + 1 * (man1.Text) + 1 * (usu1.Text) + 1 * (dis1.Text))
            cuitotal.Text = (1 * (cui1.Text) + 1 * (cui2.Text) + 1 * (cui3.Text) + 1 * (cui4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub man1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles man1.TextChanged
        If man1.Text = "" Then
            man1.Text = 0
        End If

        If Me.man1.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            man1.Text = 3
        End If
        Try
            total1.Text = (1 * (die1.Text) + 1 * (cui1.Text) + 1 * (man1.Text) + 1 * (usu1.Text) + 1 * (dis1.Text))
            mantotal.Text = (1 * (man1.Text) + 1 * (man2.Text) + 1 * (man3.Text) + 1 * (man4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub usu1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles usu1.TextChanged
        If usu1.Text = "" Then
            usu1.Text = 0
        End If
        If Me.usu1.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            usu1.Text = 3
        End If
        Try
            total1.Text = (1 * (die1.Text) + 1 * (cui1.Text) + 1 * (man1.Text) + 1 * (usu1.Text) + 1 * (dis1.Text))
            usutotal.Text = (1 * (usu1.Text) + 1 * (usu2.Text) + 1 * (usu3.Text) + 1 * (usu4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub dis1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dis1.TextChanged
        If dis1.Text = "" Then
            dis1.Text = 0
        End If
        If Me.dis1.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            dis1.Text = 3
        End If
        Try
            total1.Text = (1 * (die1.Text) + 1 * (cui1.Text) + 1 * (man1.Text) + 1 * (usu1.Text) + 1 * (dis1.Text))
            distotal.Text = (1 * (dis1.Text) + 1 * (dis2.Text) + 1 * (dis3.Text) + 1 * (dis4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub die2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles die2.TextChanged
        If die2.Text = "" Then
            die2.Text = 0
        End If
        If Me.die2.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            die2.Text = 3
        End If
        Try
            total2.Text = (1 * (die2.Text) + 1 * (cui2.Text) + 1 * (man2.Text) + 1 * (usu2.Text) + 1 * (dis2.Text))
            rentotal.Text = (1 * (die1.Text) + 1 * (die2.Text) + 1 * (die3.Text) + 1 * (die4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub die3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles die3.TextChanged
        If die3.Text = "" Then
            die3.Text = 0
        End If
        If Me.die3.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            die3.Text = 3
        End If
        Try
            total3.Text = (1 * (die3.Text) + 1 * (cui3.Text) + 1 * (man3.Text) + 1 * (usu3.Text) + 1 * (dis3.Text))
            rentotal.Text = (1 * (die1.Text) + 1 * (die2.Text) + 1 * (die3.Text) + 1 * (die4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub die4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles die4.TextChanged
        If die4.Text = "" Then
            die4.Text = 0
        End If
        If Me.die4.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            die4.Text = 3
        End If
        Try
            total4.Text = (1 * (die4.Text) + 1 * (cui4.Text) + 1 * (man4.Text) + 1 * (usu4.Text) + 1 * (dis4.Text))
            rentotal.Text = (1 * (die1.Text) + 1 * (die2.Text) + 1 * (die3.Text) + 1 * (die4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub cui2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cui2.TextChanged
        If cui2.Text = "" Then
            cui2.Text = 0
        End If
        If Me.cui2.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            cui2.Text = 3
        End If
        Try
            total2.Text = (1 * (die2.Text) + 1 * (cui2.Text) + 1 * (man2.Text) + 1 * (usu2.Text) + 1 * (dis2.Text))
            cuitotal.Text = (1 * (cui1.Text) + 1 * (cui2.Text) + 1 * (cui3.Text) + 1 * (cui4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub cui3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cui3.TextChanged
        If cui3.Text = "" Then
            cui3.Text = 0
        End If
        If Me.cui3.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            cui3.Text = 3
        End If
        Try
            total3.Text = (1 * (die3.Text) + 1 * (cui3.Text) + 1 * (man3.Text) + 1 * (usu3.Text) + 1 * (dis3.Text))
            cuitotal.Text = (1 * (cui1.Text) + 1 * (cui2.Text) + 1 * (cui3.Text) + 1 * (cui4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub cui4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cui4.TextChanged
        If cui4.Text = "" Then
            cui4.Text = 0
        End If
        If Me.cui4.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            cui4.Text = 3
        End If
        Try
            total4.Text = (1 * (die4.Text) + 1 * (cui4.Text) + 1 * (man4.Text) + 1 * (usu4.Text) + 1 * (dis4.Text))
            cuitotal.Text = (1 * (cui1.Text) + 1 * (cui2.Text) + 1 * (cui3.Text) + 1 * (cui4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub man2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles man2.TextChanged
        If man2.Text = "" Then
            man2.Text = 0
        End If
        If Me.man2.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            man2.Text = 3
        End If
        Try
            total2.Text = (1 * (die2.Text) + 1 * (cui2.Text) + 1 * (man2.Text) + 1 * (usu2.Text) + 1 * (dis2.Text))
            mantotal.Text = (1 * (man1.Text) + 1 * (man2.Text) + 1 * (man3.Text) + 1 * (man4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub man3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles man3.TextChanged
        If man3.Text = "" Then
            man3.Text = 0
        End If
        If Me.man3.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            man3.Text = 3
        End If
        Try
            total3.Text = (1 * (die3.Text) + 1 * (cui3.Text) + 1 * (man3.Text) + 1 * (usu3.Text) + 1 * (dis3.Text))
            mantotal.Text = (1 * (man1.Text) + 1 * (man2.Text) + 1 * (man3.Text) + 1 * (man4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub man4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles man4.TextChanged
        If man4.Text = "" Then
            man4.Text = 0
        End If
        If Me.man4.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            man4.Text = 3
        End If
        Try
            total4.Text = (1 * (die4.Text) + 1 * (cui4.Text) + 1 * (man4.Text) + 1 * (usu4.Text) + 1 * (dis4.Text))
            mantotal.Text = (1 * (man1.Text) + 1 * (man2.Text) + 1 * (man3.Text) + 1 * (man4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub usu2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles usu2.TextChanged
        If usu2.Text = "" Then
            usu2.Text = 0
        End If
        If Me.usu2.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            usu2.Text = 3
        End If
        Try
            total2.Text = (1 * (die2.Text) + 1 * (cui2.Text) + 1 * (man2.Text) + 1 * (usu2.Text) + 1 * (dis2.Text))
            usutotal.Text = (1 * (usu1.Text) + 1 * (usu2.Text) + 1 * (usu3.Text) + 1 * (usu4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub usu3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles usu3.TextChanged
        If usu3.Text = "" Then
            usu3.Text = 0
        End If
        If Me.usu3.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            usu3.Text = 3
        End If
        Try
            total3.Text = (1 * (die3.Text) + 1 * (cui3.Text) + 1 * (man3.Text) + 1 * (usu3.Text) + 1 * (dis3.Text))
            usutotal.Text = (1 * (usu1.Text) + 1 * (usu2.Text) + 1 * (usu3.Text) + 1 * (usu4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub usu4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles usu4.TextChanged
        If usu4.Text = "" Then
            usu4.Text = 0
        End If
        If Me.usu4.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            usu4.Text = 3
        End If
        Try
            total4.Text = (1 * (die4.Text) + 1 * (cui4.Text) + 1 * (man4.Text) + 1 * (usu4.Text) + 1 * (dis4.Text))
            usutotal.Text = (1 * (usu1.Text) + 1 * (usu2.Text) + 1 * (usu3.Text) + 1 * (usu4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub dis2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dis2.TextChanged
        If dis2.Text = "" Then
            dis2.Text = 0
        End If
        If Me.dis2.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            dis2.Text = 3
        End If
        Try
            total2.Text = (1 * (die2.Text) + 1 * (cui2.Text) + 1 * (man2.Text) + 1 * (usu2.Text) + 1 * (dis2.Text))
            distotal.Text = (1 * (dis1.Text) + 1 * (dis2.Text) + 1 * (dis3.Text) + 1 * (dis4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub dis3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dis3.TextChanged
        If dis3.Text = "" Then
            dis3.Text = 0
        End If
         If Me.dis3.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            dis3.Text = 3
        End If
        Try
            total3.Text = (1 * (die3.Text) + 1 * (cui3.Text) + 1 * (man3.Text) + 1 * (usu3.Text) + 1 * (dis3.Text))
            distotal.Text = (1 * (dis1.Text) + 1 * (dis2.Text) + 1 * (dis3.Text) + 1 * (dis4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub

    Private Sub dis4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dis4.TextChanged
        If dis4.Text = "" Then
            dis4.Text = 0
        End If
        If Me.dis4.Text > 3 Then
            MsgBox("El valor no puede ser mayor a 3", MsgBoxStyle.Exclamation, "Aviso")
            dis4.Text = 3
        End If
        Try
            total4.Text = (1 * (die4.Text) + 1 * (cui4.Text) + 1 * (man4.Text) + 1 * (usu4.Text) + 1 * (dis4.Text))
            distotal.Text = (1 * (dis1.Text) + 1 * (dis2.Text) + 1 * (dis3.Text) + 1 * (dis4.Text)) / numero
            totalG.Text = (1 * (rentotal.Text) + 1 * (cuitotal.Text) + 1 * (mantotal.Text) + 1 * (usutotal.Text) + 1 * (distotal.Text))

        Catch ex As Exception

        End Try
    End Sub
    Sub ActualizaEvaluacion()
        limpia()

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT * From EvaluacionInternaDetalle " & _
        " WHERE idempleado=" & Trim(EmpleadoID) & " and mes='" & Me.lstMeses.Text & "' and anio=" & Me.txtAnio.Text & " order by evaluacion"
        Dim rdBuscar As SqlDataReader


        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Dim Evaluacion As Integer
        Dim Rendimiento As Integer
        Dim Cuidado As Integer
        Dim Manejo As Integer
        Dim Usuario As Integer
        Dim Disponible As Integer


        Do While rdBuscar.Read()
            Evaluacion = rdBuscar("evaluacion")
            Rendimiento = rdBuscar("rendimiento")
            Cuidado = rdBuscar("cuidado")
            Manejo = rdBuscar("manejo")
            Usuario = rdBuscar("usuario")
            Disponible = rdBuscar("disponible")

            If Evaluacion = 1 Then
                eva1.Checked = True
                Me.die1.Text = Rendimiento
                Me.cui1.Text = Cuidado
                Me.man1.Text = Manejo
                Me.usu1.Text = Usuario
                Me.dis1.Text = Disponible
            End If
            If Evaluacion = 2 Then
                eva2.Checked = True
                Me.die2.Text = Rendimiento
                Me.cui2.Text = Cuidado
                Me.man2.Text = Manejo
                Me.usu2.Text = Usuario
                Me.dis2.Text = Disponible
            End If
            If Evaluacion = 3 Then
                eva3.Checked = True
                Me.die3.Text = Rendimiento
                Me.cui3.Text = Cuidado
                Me.man3.Text = Manejo
                Me.usu3.Text = Usuario
                Me.dis3.Text = Disponible
            End If
            If Evaluacion = 4 Then
                eva4.Checked = True
                Me.die4.Text = Rendimiento
                Me.cui4.Text = Cuidado
                Me.man4.Text = Manejo
                Me.usu4.Text = Usuario
                Me.dis4.Text = Disponible
            End If


        Loop

    End Sub

    Private Sub lstMeses_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstMeses.SelectedIndexChanged
        ActualizaEvaluacion()
    End Sub

    Private Sub lstMeses_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstMeses.SelectedValueChanged
        ActualizaEvaluacion()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub toolGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub toolSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ToolStripButton8_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton8.Click
        If Me.lblNombre.Text = "" Then
            MsgBox("Debes indicar un empleado", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If
        If Me.lstMeses.Text = "" Then
            MsgBox("Debes indicar un mes", MsgBoxStyle.Exclamation, "Aviso")
            Exit Sub
        End If
        'Primero Borrar Anteriores
        EvaDeta.IdEmpleado = Trim(EmpleadoID)
        EvaTotal.IDEmpleado = Trim(EmpleadoID)
        EvaDeta.Mes = Me.lstMeses.Text
        EvaTotal.Mes = Me.lstMeses.Text
        EvaDeta.Anio = Me.txtAnio.Text.Trim
        EvaTotal.Anio = Me.txtAnio.Text.Trim
        EvaDeta.Borrar()
        EvaTotal.Borrar()

        If eva1.Checked = True Then
            EvaDeta.IdEvaluacionInternaDetalle = (BuscarIntDatoCitra("SELECT MAX(IdEvaluacionInternaDetalle) as ID FROM EvaluacionInternaDetalle")) + 1
            EvaDeta.IdEmpleado = Trim(EmpleadoID)
            EvaDeta.Evaluacion = 1
            EvaDeta.Mes = Me.lstMeses.Text
            EvaDeta.Anio = Me.txtAnio.Text.Trim
            EvaDeta.Rendimiento = Me.die1.Text
            EvaDeta.Cuidado = Me.cui1.Text
            EvaDeta.Manejo = Me.man1.Text
            EvaDeta.Usuario = Me.usu1.Text
            EvaDeta.Disponible = Me.dis1.Text
            EvaDeta.Insertar()
        End If
        If eva2.Checked = True Then
            EvaDeta.IdEvaluacionInternaDetalle = (BuscarIntDatoCitra("SELECT MAX(IdEvaluacionInternaDetalle) as ID FROM EvaluacionInternaDetalle")) + 1
            EvaDeta.IdEmpleado = Trim(EmpleadoID)
            EvaDeta.Evaluacion = 2
            EvaDeta.Mes = Me.lstMeses.Text
            EvaDeta.Anio = Me.txtAnio.Text.Trim
            EvaDeta.Rendimiento = Me.die2.Text
            EvaDeta.Cuidado = Me.cui2.Text
            EvaDeta.Manejo = Me.man2.Text
            EvaDeta.Usuario = Me.usu2.Text
            EvaDeta.Disponible = Me.dis2.Text
            EvaDeta.Insertar()
        End If
        If eva3.Checked = True Then
            EvaDeta.IdEvaluacionInternaDetalle = (BuscarIntDatoCitra("SELECT MAX(IdEvaluacionInternaDetalle) as ID FROM EvaluacionInternaDetalle")) + 1
            EvaDeta.IdEmpleado = Trim(EmpleadoID)
            EvaDeta.Evaluacion = 3
            EvaDeta.Mes = Me.lstMeses.Text
            EvaDeta.Anio = Me.txtAnio.Text.Trim
            EvaDeta.Rendimiento = Me.die3.Text
            EvaDeta.Cuidado = Me.cui3.Text
            EvaDeta.Manejo = Me.man3.Text
            EvaDeta.Usuario = Me.usu3.Text
            EvaDeta.Disponible = Me.dis3.Text
            EvaDeta.Insertar()
        End If
        If eva4.Checked = True Then
            EvaDeta.IdEvaluacionInternaDetalle = (BuscarIntDatoCitra("SELECT MAX(IdEvaluacionInternaDetalle) as ID FROM EvaluacionInternaDetalle")) + 1
            EvaDeta.IdEmpleado = Trim(EmpleadoID)
            EvaDeta.Evaluacion = 4
            EvaDeta.Mes = Me.lstMeses.Text
            EvaDeta.Anio = Me.txtAnio.Text.Trim
            EvaDeta.Rendimiento = Me.die4.Text
            EvaDeta.Cuidado = Me.cui4.Text
            EvaDeta.Manejo = Me.man4.Text
            EvaDeta.Usuario = Me.usu4.Text
            EvaDeta.Disponible = Me.dis4.Text
            EvaDeta.Insertar()
        End If

        EvaDeta.IdEvaluacionInternaDetalle = (BuscarIntDatoCitra("SELECT MAX(IdEvaluacionInternaDetalle) as ID FROM EvaluacionInternaDetalle")) + 1
        EvaTotal.IDEmpleado = Trim(EmpleadoID)
        EvaTotal.Mes = Me.lstMeses.Text.Trim
        EvaTotal.Anio = Me.txtAnio.Text.Trim
        EvaTotal.Total = Me.totalG.Text.Trim
        EvaTotal.Insertar()
        Dim EmpleadoSelect As String = BuscarStrDatoCitra("Empleados", "NombreCompleto", "IdEmpleado=" & EmpleadoID)

        'Registra actividad
        Bitacora.RegistraActividad("Realizó la evaluacion interna de " & EmpleadoSelect)

        MsgBox("Guardado Exitoso", MsgBoxStyle.Information, "Aviso")
    End Sub

    Private Sub ToolStripButton5_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton5.Click
        cont2 = cont2 + 1
        If ((valorRowSelect.Index + cont) - (cont2)) < 0 Then
            MsgBox("No hay mas registros para mostrar en el filtro", MsgBoxStyle.Exclamation, "Aviso")
            cont2 = cont2 - 1
            Exit Sub
        End If


        EmpleadoID = frmModuloEmpleados.dgEmpleados.Rows((valorRowSelect.Index + cont) - (cont2)).Cells(0).Value.ToString.Trim
        Dim EmpleadoSelect As String = BuscarStrDatoCitra("Empleados", "NombreCompleto", "IdEmpleado=" & EmpleadoID)
        Me.lblNombre.Text = EmpleadoSelect
        ActualizaEvaluacion()
    End Sub

    Private Sub ToolStripButton7_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton7.Click
        cont = cont + 1
        If cont - cont2 > limite Then
            MsgBox("No hay mas registros para mostrar en el filtro", MsgBoxStyle.Exclamation, "Aviso")
            cont = cont - 1
            Exit Sub
        End If
        EmpleadoID = frmModuloEmpleados.dgEmpleados.Rows((valorRowSelect.Index + cont) - (cont2)).Cells(0).Value.ToString.Trim
        Dim EmpleadoSelect As String = BuscarStrDatoCitra("Empleados", "NombreCompleto", "IdEmpleado=" & EmpleadoID)
        Me.lblNombre.Text = EmpleadoSelect
        ActualizaEvaluacion()
    End Sub

    Private Sub ToolStripButton4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton4.Click
        Close()

    End Sub
End Class